package com.moran.beetlsql.learn.dao;

import com.moran.beetlsql.common.BaseDao;
import com.moran.beetlsql.learn.bean.WebsitesBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description
 * @Author wnf
 * @Date 2025-07-10
 */
@Repository
public class WebsitesDao extends BaseDao {

    @Autowired
    @Qualifier("testJdbcTemplate")
    private JdbcTemplate jdbcTemplateTest;

    /*
     * 通过JDBC依赖注入查询数据
     */
    public List<WebsitesBean> queryWebsitesList() {
        String sql = "select * from websites";
        return jdbcTemplateTest.query(sql, new Object[]{}, new BeanPropertyRowMapper<>(WebsitesBean.class));
    }
}
